package com.k.ums.util;

import io.jsonwebtoken.*;

import java.util.Map;

/**
 * @Description:
 * @Author: kt
 * @CreateTime: 2022/2/21
 */
public class JwtUtils {
    private static final String JWT_SECRET_KEY = "3d990d2276917dfac04467df11fff26d";

    public static String createJwt(Map<String, Object> claims) {
        return Jwts.builder()
                .setClaims(claims)
                .signWith(SignatureAlgorithm.HS512, JWT_SECRET_KEY)
                .compact();
    }

    public static Claims parseJwt(String jwt) {
        return Jwts.parser()
                .setSigningKey(JWT_SECRET_KEY)
                .parseClaimsJws(jwt)
                .getBody();
    }
}
